<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%String path = request.getContextPath(); %>
<jsp:include page="/manage/inc/head.jsp"></jsp:include>
<jsp:include page="/manage/inc/menu.jsp"></jsp:include>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="/jscss/admin/design/">首页</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="<%=path%>/FoodManageServlet?action=getAllIngredientsType">食材管理</a><span class="crumb-step">&gt;</span><span>新增一级分类</span></div>
        </div>
        <div class="result-wrap">
            <div class="result-content">
                <form action="<%=path %>/FoodManageServlet?action=addIngredientsType" method="post" id="myform" name="myform" >
                    <table class="insert-tab" width="100%">
                        <tbody>
                       
                            <tr>
                                <th><i class="require-red">*</i>分类名称：</th>
                                <td>
                                    <input class="common-text required" id="title" name="title" size="50" value="" type="text">
                                    <span id="sp" style="color:red;"></span>
                                </td>
                            </tr> 
                            <tr>
                                <th></th>
                                <td>
                                    <input class="btn btn-primary btn6 mr10" id="sub" value="提交" type="button">
                                    <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
                                </td>
                            </tr>
                        </tbody></table>
                </form>
            </div>
        </div>

    </div>
    <!--/main-->
    <jsp:include page="/manage/inc/foot.jsp"></jsp:include>
    <script>
    //判断分类名称不能为空
    $(function(){
    	$("#sub").click(function(){
    		var val=$("#title").val();
    		if(val==""){
    			$("#sp").html("不能为空！");
    			$("#title").select();
    		}else{
    			$("#sp").html("");
    			$.ajax({
    				url:"<%=path %>/FoodManageServlet?action=IngredientsTypeRepeat",
    				data:{title:val},
    				success:function(mes){
    					if(mes=="ok"){
    						$("#myform").submit();
    						$("#sp").html("");
    					}else{
    						$("#sp").html("类型名重复");
    					}
    				}
    			});
    		}
    	})
    });
    </script>